// Aufgabe_10_3_Windraeder

var windrad_01;
var windrad_02;
var windrad_03;
var windrad_04;

function setup() {
  createCanvas(800, 400);
  // Die Eigenschaften der einzelnen Windräder werden festgelegt.
                        //  x    y    s    h   r   w    n
  windrad_01 = new Windrad(100, 200, 1.0, 300, 0, 0.01, 4);
  windrad_02 = new Windrad(200, 300, 0.4, 50, 0, 0.08, 12);
  windrad_03 = new Windrad(400, 150, 1.5, 100, 0, 0.02, 24);
  windrad_04 = new Windrad(650, 250, 0.8, 360, 0, 0.04, 18);
}

function draw(){
  colorMode(HSB,360, 100, 100);
  background(200, 100, 100);

  windrad_01.display();
  windrad_02.display();
  windrad_03.display();
  windrad_04.display();
	}

// Konstruktor
function Windrad(tempX, tempY, tempS, tempH, tempR, tempW, tempN){

  this.x = tempX;
  this.y = tempY;
  this.s = tempS;
  this.h = tempH;
  this.w = tempW;
  this.n = tempN;
  this.r = tempR;

// Methode
  this.display = function(){
  push();
  translate(this.x, this.y);
  scale(this.s);

 // Stange
  stroke(34, 100, 80);
  strokeWeight(15);
  line(0, 400, 0, 0);

 // Achse
  noStroke();
  fill(36, 100, 100);
  ellipse(0, 0, 30, 30);

 // Rotation der Rotorblätter
  rotate(this.r);
  this.r = this.r + this.w;

 // Rotorblätter
  for(var i = 0; i < this.n; i++){
   stroke(100, 0, 100);
   strokeWeight(1);
   fill(this.h, 100, 100);
   ellipse(0, 50, 20, 80);
   rotate(PI/(this.n/2));
  }
 pop();
 }
}
